var AES = require('./aes.js')

var key = "1234567890123465";
var iv = "1201230125466688";
Page({
  data: {
    output: '上方输入框输入数据后点击下方对应按钮转换',
    toEncryptInput: '',
    toDecryptInput: ''
  },
  bindEncryptInput: function (e) {
    this.setData({
      toEncryptInput: e.detail.value
    })
  },
  aesEncrypt: function () {
    var encStr = AES.encrypt(this.data.toEncryptInput, key, iv);
    this.setData({
      toDecryptInput: encStr
    })
    wx.setClipboardData({
      data: encStr,
      success: function () {
        wx.showToast({
          title: '复制成功',
          duration: 1000
        })
      }
    })
  },
  aesDecrypt: function () {
    var decStr = AES.decrypt(this.data.toDecryptInput, key, iv);
    this.setData({
      toEncryptInput: decStr
    })
    wx.setClipboardData({
      data: decStr,
      success: function () {
        wx.showToast({
          title: '复制成功',
          duration: 1000
        })
      }
    })
  }
})